package info.androidhive.slidingmenu;

import java.util.ArrayList;
import java.util.HashMap;

import android.graphics.Color;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ImageListFragmentAdapter extends BaseAdapter {

	private static String[] IMGS;
	private final ImageDownloader imageDownloader = new ImageDownloader();

	public ImageListFragmentAdapter(ArrayList<HashMap<String, String>> mylist) {
		// TODO Auto-generated constructor stub
		IMGS = new String[mylist.size()];

		for (int i = 0; i < mylist.size(); i++) {
			IMGS[i] = mylist.get(i).get("goodcd").toString();
		}
	}

	public int getCount() {
		return IMGS.length;
	}

	public String getItem(int position) {
		return IMGS[position];
	}

	public long getItemId(int position) {
		return IMGS[position].hashCode();
	}

	public View getView(int position, View view, ViewGroup parent) {
		if (view == null) {
			view = new ImageView(parent.getContext());
			view.setPadding(0, 0, 0, 0);

		}

		imageDownloader.download("http://www.dongpang.co.kr/images/userdif/goodsColor/" + IMGS[position] + "-1S.jpg", (ImageView) view);

		return view;
	}

	public ImageDownloader getImageDownloader() {
		return imageDownloader;
	}

}
